<%@page import="com.hrms.pojo.Pay"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String basePath=request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=basePath%>/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
	function checkinput() {
		var nubmer = $("#pageIndex").val();
		if (isNaN(nubmer)) {
			alert("请输入数字");
			$("#pageIndex").val("");
			return false;
		}
	}
</script>
<title>分页查看薪资信息</title>
<title>工资清单</title>
</head>
<body>
		<table>
			<tr>
				<td>员工编号</td>
				<td>员工姓名</td>
				<td>当前月份</td>
				<td>基本工资</td>
				<td>加班费</td>
				<td>工龄费</td>
				<td>考勤费</td>
				<td>旷工费</td>
				<td>保险费</td>
				<td>实发工资</td>
				<td>操作</td>
			</tr>
			<%
				Object obj=request.getAttribute("payList");
				Object objs=session.getAttribute("allPay");
				List<Pay>payList=(List<Pay>)obj;
				List<Pay>allPay=(List<Pay>)objs;
				int size=5;
				int pageCount=(allPay.size()%size==0?allPay.size()/size:allPay.size()/size+1);
				int payAgeSalary=0;
				int salary=0;
				for(Pay pay:payList){
					payAgeSalary=50*pay.getPayAge();
					salary=pay.getPayBase()+pay.getPayOvertime()+payAgeSalary+pay.getPayCheck()-pay.getPayAbsent()-pay.getPaySafety();
			%>
			<tr>
				<td><%=pay.getPayEmNumber() %></td>
				<td><%=pay.getPayEmName() %></td>
				<td><%=pay.getPayGrantTime() %></td>
				<td><%=pay.getPayBase() %></td>
				<td><%=pay.getPayOvertime() %></td>
				<td><%=payAgeSalary %></td>
				<td><%=pay.getPayCheck() %></td>
				<td><%=pay.getPayAbsent() %></td>
				<td><%=pay.getPaySafety() %></td>
				<td><%=salary %></td>
				<td><a href="<%=basePath %>/pay/<%=pay.getPayId() %>/removePayById">删除</a></td>
			</tr>
			<%
				}
			%>
		</table>
		<div id="page">
			<%
				Integer showPage=(Integer)(session.getAttribute("pageIndex"));
			%>
			<span>第<%=showPage%>页/共<%=pageCount%>页 <a
				href="<%=basePath%>/pay/limit?pageIndex=1">首页</a>&nbsp;
				<a
				href="<%=basePath%>/pay/limit?pageIndex=<%=showPage - 1%>">上一页</a>
				&nbsp; <a
				href="<%=basePath%>/pay/limit?pageIndex=<%=showPage + 1%>">下一页</a>&nbsp;
				<a
				href="<%=basePath%>/pay/limit?pageIndex=<%=pageCount%>">尾页</a></span>&nbsp;
			<form action="<%=basePath%>/pay/limit" onsubmit="return checkinput()">
				跳转到第<input type="text" name="pageIndex" id="pageIndex" size="1">页<input
					type="submit" value="GO">
			</form>
		</div>
		<div id="addPay">
			<a href="<%=basePath %>/pay/addPay">添加薪资</a>
		</div>
		<div id="return">
			<a href="<%=basePath%>/admin/function">返回功能页面</a>
		</div>
</body> 
</html>